package com.blog.handler;

import com.blog.common.result.R;
import com.blog.common.result.ResponseEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public R exceptionHandler(Exception e) {
        log.error(e.getMessage());
        if (e.getMessage().contains("convert_content")) {
            return R.error("内容过长了");
        }
        return R.error(e.getMessage());
    }
}
